package string;


public class StringDemo {
    public static void main(String[] args) {
        String s1 = new String("hello world");
        String s2 = "hello world";
        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));
    /*    String s1 = "123abc";
        String s2 = "123" + "abc";
        //两个字面量相连,会最直接连接好并把结果保存起来
        System.out.println(s1 == s2);
        String s3 = "123";
        String s4 = s3 + "abc";
        //因为s3是一个变量,所以编译期不会直接编译好
        System.out.println(s1 == s4);*/






    /*    String s1 = "123";
        String s2 = "123";
        System.out.println(s1 == s2);
        s1 = "123" + "!";
        System.out.println(s1 == s2);*/
    }
}
